package ch.sfug.anim.tween.property {	import ch.sfug.anim.tween.AbstractTween;		    
	/**	 * @author mich	 */	public class PropertyTween extends AbstractTween {
		private var pps:Object;
		public function PropertyTween( d:Object, dur:uint ) {			super(d, dur);		}
		
		/**		 * overwrite superfunction to interpolate on the properties		 */		override protected function interpolate( c:Number, d:Number ):void {			var t:Object = super.target;			for( var i:String in pps ) {				var p:Object = pps[ i ];				t[ i ] = p.easing(c, p.from, p.to - p.from, d);			}			super.interpolate( c, d );		}
		
		/**		 * tween to a specified object		 * @param obj an object that looks like this:		 * { x: { from:200, to: 300, easing:func } }		 * or		 * { x: { to: 300, easing:func } } // starts from the actual _x property		 * or		 * { x: { by: 300, easing:func } } // starts from the actual _x property with the amount of 300		 */		public function tween( obj:Object ):void {			for( var i:String in obj ) {				var p:Object = obj[ i ];				if( p.easing == null ) p.easing = linear;				if( p.from == null ) p.from = super.target[ i ];				// parse by				if( p.by != null ) p.to = p.from + p.by;			}			this.pps = obj;			this.start();		}
		
		/**		 * applies property values to the object		 * @param obj an object that looks like this:		 * { _x:200, _y:300 }		 */		public function apply( obj:Object ):void {			for (var i:String in obj ) {				target[ i ] = obj[ i ];			}		}	}}